package com.jim.study.delicacy_bjx.controller;

import com.alibaba.fastjson.JSONObject;
import com.jim.study.delicacy_bjx.dao.DelicacyMapper;
import com.jim.study.delicacy_bjx.service.DelicacyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
public class DelicacyController {

    @Autowired
    private DelicacyMapper delicacyMapper;

    @Autowired
    private DelicacyService delicacyService;

    /**
     * 获取热度top10的菜
     * @return
     */
    @RequestMapping(value = "/top10heat",method = RequestMethod.GET)
    public Object getTopDelicaciesByHeat(){
        return delicacyMapper.getTopDelicaciesByHeat();
    }

    /**
     * 随机获取一道菜
     * @return
     */
    @RequestMapping(value = "/daily",method = RequestMethod.GET)
    public Object tipDelicacyDaily(){
        return delicacyMapper.tipDelicacyDaily();
    }

    /**
     * 获取所有菜
     * @return
     */
    @RequestMapping(value = "/allDelicacies",method = RequestMethod.GET)
    public Object getAllDelicacies(){
        return "";
    }

    /**
     * 根据条件查询菜
     * @param data
     * @return
     */
    @RequestMapping(value = "/targetDelicacies",method = RequestMethod.POST)
    public Object getTargetDelicacies(@RequestBody JSONObject data){
        return delicacyService.selectDelicacy(data);
    }

    /**
     * 根据用户偏好查询菜品
     * @param username
     * @return
     */
    @RequestMapping(value = "/recommendDelicacies",method = RequestMethod.POST)
    public Object recommendDelicacies(@RequestParam("username") String username){
        return delicacyService.selectPreferenceDelicacy(username);
    }
}
